<template>
    <div class="content-box">
        <div class="team-info clearfix">
            <x-img class="logo" :src="$route.query.icon"/><span>{{$route.query.name}}</span>
        </div>
        <ul class="team clearfix">
            <li class="team-item" v-for="item in race_team_manage_list.list" v-bind:key="item.id">
                <avatar class="avatar" v-bind:src="item.userIcon"/>
                <p class="player-name"><span>{{item.nickName}}</span></p>
                <p class="card-no">{{item.idNo}}</p>
                <p class="card-no"><span class="sex" v-if="item.sex === 1">男</span><span class="sex" v-else>女</span></p>
                <p class="detail"><a @click="showManageList(item.userId)">查看详细资料</a></p>
            </li>
        </ul>
        <!--无数据提示-->
        <placeholder text="暂无参赛人员" src="/static/images/match/nomatch.png" v-if="race_team_manage_list.total === 0"></placeholder>
        <!--分页-->
        <el-pagination
          v-bind="getPaginationProps(race_team_manage_list)"
          @current-change="handleCurrentChange"
          @size-change="handleSizeChange">
        </el-pagination>
        <div class="button-box">
          <el-button type="primary" v-if="race_team_manage_list.total > 0" @click="exportExcel">导出Excel</el-button>
        </div>
        <el-dialog title="查看详细资料" :visible.sync="dialogVisible" size="tiny" top="35%">
          <div class="managebox">
            <el-row>
              <el-col :span="6"><div class="grid-content bg-purple right">姓名：</div></el-col>
              <el-col :span="18"><div class="grid-content bg-purple-light">{{race_player_list.userName}}</div></el-col>
            </el-row>
            <el-row>
              <el-col :span="6"><div class="grid-content bg-purple right">性别：</div></el-col>
              <el-col :span="18"><div class="grid-content bg-purple-light"><span v-if="race_player_list.sex === 1">男</span><span v-else>女</span></div></el-col>
            </el-row>
            <el-row v-if="race_player_list.userAge">
              <el-col :span="6"><div class="grid-content bg-purple right">年龄：</div></el-col>
              <el-col :span="18"><div class="grid-content bg-purple-light">{{race_player_list.userAge}}</div></el-col>
            </el-row>
            <el-row v-if="race_player_list.height">
              <el-col :span="6"><div class="grid-content bg-purple right">身高：</div></el-col>
              <el-col :span="18"><div class="grid-content bg-purple-light">{{race_player_list.height}}</div></el-col>
            </el-row>
            <el-row v-if="race_player_list.weight">
              <el-col :span="6"><div class="grid-content bg-purple right">体重：</div></el-col>
              <el-col :span="18"><div class="grid-content bg-purple-light">{{race_player_list.weight}}</div></el-col>
            </el-row>
            <el-row>
              <el-col :span="6"><div class="grid-content bg-purple right">身份证号：</div></el-col>
              <el-col :span="18"><div class="grid-content bg-purple-light">{{race_player_list.idNo}}</div></el-col>
            </el-row>
          </div>
        </el-dialog>
    </div>
</template>

<script>
  import { mapGetters } from 'vuex'
  import { downloadFile } from 'utils'
  import { pagingList } from 'utils/mixins'
  export default {
    mixins: [pagingList],
    computed: {
      ...mapGetters({
        race_team_manage_list: 'race_team_manage_list',
        race_player_list: 'race_player_list'
      })
    },
    data () {
      return {
        dialogVisible: false,
        query: this.getQuery()
      }
    },
    methods: {
      // 成员列表
      fetch (query) {
        Object.assign(query, {matchId: this.$route.query.id, orgId: this.$route.query.orgId})
        this.$store.dispatch('race_team_manage_list', query)
      },
      // 导出成员
      exportExcel () {
        let name = this.$route.query.name + '成员列表.xls'
        let url = '/api/match/sign/export/teamUser?matchId=' + this.$route.query.id + '&userId=' + this.$route.query.orgId
        downloadFile(url, name)
      },
      // 查看成员详细资料
      showManageList (userId) {
        this.dialogVisible = true
        this.$store.dispatch('race_player_list', {matchId: this.$route.query.id, userId: userId})
      }
    }

  }
</script>

<style lang="scss">
  .no_matchlist{
    text-align: center;
    color:#999;
  }
  .el-dialog--tiny{
    min-width: 570px;
  }
  .managebox{
    .right{
      text-align: right;
    }
    line-height: 2;
  }
  .team-item {
      width: 193px;
      border: 1px solid #e9e9e9;
      float: left;
      margin-right: 19px;
      padding: 30px 0;
      text-align: center;
      margin-bottom: 20px;
  }

  .team {
      .team-item {
          &:nth-child(4n) {
              margin-right: 0;
          }
      }
  }

  .player-name {
      margin: 25px 0 20px 0;
      font-size: 14px;
  }

  .team-info {
      margin-bottom: 20px;
      .logo {
        width: 38px;
        height: 38px;
        border-radius: 50%;
      }
      span {
          line-height: 40px;
          margin-left: 20px;
          font-size: 16px;
      }
  }

  .team-info img, .team-info span {
      display: inline-block;
      float: left;
  }

  .avatar {
      width: 60px;
      height: 60px;
      border-radius: 50%;
  }

  .sex {
      font-size: 14px;
      margin-left: 10px;
  }

  .card-no {
      font-size: 12px;
      color: #666;
      margin: 15px 0;
  }

  .detail {
      margin-top: 25px;
      color: #3983e5;
      cursor: pointer;
  }

  .more {
      display: block;
      width: 100%;
      height: 40px;
      line-height: 40px;
      color: #333;
      background: #f1f2f3;
      text-align: center;
  }
</style>
